package commRedis

import (
	"gitee.com/fierce_wolf/go-fox-edge-common/commEnv"
	"github.com/go-redis/redis"
)

var (
	Options *redis.Options
	Client  *redis.Client
)

func init() {
	host, ok := commEnv.GetArg("redis.host")
	if !ok {
		panic("缺失参数：redis.host")
	}

	port, ok := commEnv.GetArg("redis.port")
	if !ok {
		panic("缺失参数：redis.port")
	}

	password, ok := commEnv.GetArg("redis.password")
	if !ok {
		panic("缺失参数：redis.password")
	}

	if host == "" {
		host = "localhost"
	}
	if port == "" {
		port = "6379"
	}

	Options = &redis.Options{
		Addr:     host.(string) + ":" + port.(string),
		Password: password.(string),
		DB:       0,
	}
}
